-- 缺水的掌握怒海
local queshuidezhangwonuhai = fk.CreateSkill{
    name = "mcdh_queshuidezhangwonuhai",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

queshuidezhangwonuhai:addEffect(fk.TargetSpecified,{
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and data.to ~= player and data:isOnlyTarget(data.to)
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        if room:askToSkillInvoke(player, {skill_name = self.name,prompt="#mcdh__QueShuiDeZhangWoNuHai-invoke:" .. data.from.id}) then
            lib.mcdh_charge(player, -2)
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local ids = player:drawCards(2, self.name)
        player:showCards(ids)
        for i = 1, #ids do
            local card = Fk:getCardById(ids[i])
            if card.type == Card.TypeBasic then
                if #room:askToDiscard(player,{min_num=1,max_num=1,include_equip=true,skill_name=self.name,pattern="jink",prompt= "#mcdh__QueShuiDeZhangWoNuHai-askdiscard:",cancelable=true} ) == 0 then
                    lib.Damage(
                            {
                                from = nil,
                                to = player,
                                damage = 1,
                                skillName = self.name,
                            }
                    )
                end
                break
            end
        end
    end
})

queshuidezhangwonuhai:addEffect(fk.TargetConfirmed,{
    can_trigger = function(self, event, target, player, data)
        if target ~= player or not player:hasSkill(self) then
            return false
        end
        if player:getMark("mcdh_charge") < 2 then
            return false
        end
        if #data:getAllTargets() ~= 1 then
            return false
        end
        return (data.from == player) ~= (data.to == player)
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        if room:askToSkillInvoke(player, {skill_name=self.name,prompt= "#mcdh__QueShuiDeZhangWoNuHai-invoke:" .. data.from.id}) then
            lib.mcdh_charge(player, -2)
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local ids = player:drawCards(2, self.name)
        player:showCards(ids)
        for i = 1, #ids do
            local card = Fk:getCardById(ids[i])
            if card.type == Card.TypeBasic then
                if #room:askToDiscard(player,{min_num=1,max_num=1,include_equip=true,skill_name=self.name,pattern="jink",prompt= "#mcdh__QueShuiDeZhangWoNuHai-askdiscard:",cancelable=true} ) == 0 then
                    lib.Damage(
                            {
                                from = nil,
                                to = player,
                                damage = 1,
                                skillName = self.name,
                            }
                    )
                end
                break
            end
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_queshuidezhangwonuhai"] = "擎海",
    [":mcdh_queshuidezhangwonuhai"] = "『缺水的掌握怒海』<br><a href='charge_skill'>蓄力技(2)</a>，当你使用牌指定一名其他角色为唯一目标后，或成为一名其他角色使用牌的唯一目标后，" ..
            "你可以摸两张牌并展示，若其中有基本牌，你除非弃置一张【闪】，否则受到1点无来源伤害。",

    ["#mcdh__QueShuiDeZhangWoNuHai-invoke"] = "缺水的掌握怒海：摸两张牌，然后弃置【闪】或受到伤害",
    ["#mcdh__QueShuiDeZhangWoNuHai-askdiscard"] = "弃置一张【闪】，或取消并受到1点伤害",
}

return queshuidezhangwonuhai

